/*
 * paymentBO.java
 *
 * Created on March 17, 2007, 2:14 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package edu.byu.isys413.mystuff;

/**
 *
 * @author Sam Griffiths
 */
public class tlineBO {
    
    private String tlineid;
    private String transacid;
    private revBO rev = null;
    private couponBO cou = null;
    private String revid;
    private boolean dirty = false;   
    private boolean alreadyInDatabase = false;
    
    /** Creates a new instance of customerBO */
    public tlineBO() {
    }
        
    //creates new transactionline with id initialized
    public tlineBO(String tlineid) {
    this.tlineid = tlineid;
    }
    
    //returns transactionlineid
    public String getTransactionLineId() {
        return tlineid;
    }

    //returns the transaction id this transactionline is a part of
    public String getTransactionId() {
        return transacid;
    }

    //set transaction id this transactionline points to
    public void setTransactionId(String transacid) {
        this.transacid = transacid;
        setDirty(true);
    }

    //return revenue source
    public String getRevSource() {
        return revid;
    }

    //set revenue Source
    public void setRevSource(String revid) {
        this.revid = revid;
        setDirty(true);
    }

    //returns the object as a string
    public String toString(){
        return "TLine id  : "+ this.getTransactionLineId()+" \n"+
               "Transac id: "+ this.getTransactionId()+" \n"+
               "Revid     : "+ this.getRevSource() +" \n";
    }

    //returns the associated couponBO
    public couponBO getCoupon(){
        return cou;
    }
    
    //set the associated coupon
    public void setCoupon(couponBO cou){
        this.cou = cou;
    }
    
    //get associate revenue BO
    public revBO getRevenueSource(){
        return rev;
    }

    //set associated revenue BO
    public void setRevenueSource(revBO rev){
        this.rev = rev;
    }
    
    //This returns the price of the revenueSource - the coupon
    public double getPrice(){
        double p = 0;
        if(rev!=null)
            p += rev.getPrice();
        if(cou!=null)
            p -= cou.getAmount();
        return p;
    }
    
    //this returns if object has been changed since it was last read or saved
    public boolean isDirty() {
        return dirty;
    }

    //this sets the dirty
    public void setDirty(boolean dirty) {
        this.dirty = dirty;
    }

    //returns if object is already in database
    public boolean isAlreadyInDatabase() {
        return alreadyInDatabase;
    }

    //sets if object is already in database
    public void setAlreadyInDatabase(boolean alreadyInDatabase) {
        this.alreadyInDatabase = alreadyInDatabase;
    }
}